<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <th:block th:include="include :: header('人员良好行为记录编辑')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <link href="../static/css/workboard.css" th:href="@{/css/workboard.css}" rel="stylesheet"/>
</head>
<style>
.tdContent{
	position:relative
}
input.error, select.error {
    background-color: #fbe2e2;
    border-color: #c66161;
    color: #c00;
}
label.error {
    position: absolute;
    right: 48px;
    top: 8px;
    color: #ef392b;
    font-size: 12px;
}
</style>
<body>
    <div class="container-div">
        <div class="tabsbody ">
            <div class="tabsbody-item active">
                <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
                    <tbody>
                        <tr>
                            <td>
                                <div class="page-title">
                                    <span>人员良好行为记录</span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <form id="formsubmit">
                                    <table cellpadding="0" cellspacing="0" class="tbEidt"
                                        style="width: 100%;word-break:break-all;background-color: #ffffff;">
                                        <tbody>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px">良好行为代码<font color="red">*
                                                    </font>
                                                </td>
                                                <td class="tdContent" style="text-align: left;">
                                                	<input type="hidden" name="IGMIntegrityApplyInfoGuid" style="width:90%;" readonly="readonly"  th:value="${applyInfo}==null or ${applyInfo.Guid}==null ? ' ':${applyInfo.Guid}">
                                                	<input type="hidden" name="Guid" style="width:90%;" readonly="readonly"  th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.Guid}==null ? ' ':${personalWellInfoEntity.Guid}">
                                                    <input type="text" id="BehaviorCode" name="BehaviorCode" style="width:90%;" readonly="readonly" th:value="${StandardEntity}==null or ${StandardEntity.BehaviorCode}==null ? ' ':${StandardEntity.BehaviorCode}">
                                                    <span id="btnBehavior" class="OpenWin" shiro:hasPermission="integrityInformationAdd:personGoodBehavior:selectlist" onclick="addpeopleBehavior('选择人员良好行为信用评分标准','人员良好行为')"></span>
                                                </td>
                                                <td class="tdTitle">良好行为类别</td>
                                                <td class="tdContent">
                                                	<input type="text" readonly="readonly" name="BehaviorCategory" style="width:100%;border:0;outline:none;" th:value="${StandardEntity}==null or ${StandardEntity.BehaviorCategory}==null ? ' ':${StandardEntity.BehaviorCategory}">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="width: 18%;">良好行为描述</td>
                                                <td class="tdContent" colspan="3">
                                                	<textarea name="BehaviorDescription" readonly="readonly" rows="3" cols="20"
                                                        style="width:100%;border:0;outline:none;" th:text="${StandardEntity}==null or ${StandardEntity.BehavioDescription}==null ? ' ':${StandardEntity.BehavioDescription}"></textarea>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle">加分分值<font color="red">*</font>
                                                </td>
                                                <td class="tdContent" id="Score">
                                                	<!-- <input type="text" readonly="readonly" name="Score" style="width:100%;border:0;outline:none;color:red">
                                                    <select name="Score" style="width:99.5%;height: 28px;line-height: 150%;display:none;">
                                                    </select> -->
                                                </td>
                                                <td class="tdContent" colspan="2">有效期内累加上限分数：
                                                	<input type="text" readonly="readonly" name="MaxScores" style="width:20%;border:0;outline:none;color:red" th:value="${StandardEntity}==null or ${StandardEntity.MaxScores}==null ? ' ':${StandardEntity.MaxScores}">
                                                    	已加分数：
                                                    <input type="text" readonly="readonly" name="PointsAdded" style="width:20%;border:0;outline:none;color:red" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.PointsAdded}==null ? ' ':${personalWellInfoEntity.PointsAdded}">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 50px;">获奖内容
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent" colspan="3">
                                                    <textarea name="AwardContent" rows="3" cols="20"
                                                        style="width:100%;" th:text="${personalWellInfoEntity}==null or ${personalWellInfoEntity.AwardContent}==null ? ' ':${personalWellInfoEntity.AwardContent}"></textarea>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px; width: 18%;">姓名
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%; text-align: left;">
                                                    <input name="PersonName" id="PersonName" type="text" maxlength="100" style="width:90%;" readonly="readonly" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.PersonName}==null ? ' ':${personalWellInfoEntity.PersonName}">
                                                    <input name="PersonGuid" type="hidden" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.PersonGuid}==null ? ' ':${personalWellInfoEntity.PersonGuid}">
                                                    <span id="btnCompany" class="OpenWin" shiro:hasPermission="person:personall:list" onclick="selectPeople('选择人员 ')"></span>
                                                </td>
                                                <td class="tdTitle" style="width: 18%;">
									                                                    证件类型<font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%">
                                                	<select th:field="${personalWellInfoEntity.IDCardTypeNum}" name="IDCardTypeNum" id="IDCardTypeNum">
														<option selected="selected" value="">请选择</option>
														<option value="大陆身份证">大陆身份证</option>
														<option value="香港身份证">香港身份证</option>
														<option value="护照">护照</option>
														<option value="军官证">军官证</option>
														<option value="澳门身份证">澳门身份证</option>
														<option value="台湾身份证">台湾身份证</option>
														<option value="其他">其他</option>
													</select>
                                                </td>
                                            </tr>
                                             <tr>
                                            	<td class="tdTitle" style="height: 32px; width: 18%;">证件号码
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%; text-align: left;">
                                                    <input name="IDCard" id="IDCard" type="text" maxlength="100" style="width:90%;" readonly="readonly" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.IDCard}==null ? ' ':${personalWellInfoEntity.IDCard}">
                                                </td>
                                                <td class="tdTitle" style="width: 18%;">
									                                                    工程名称<font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%">
                                                	<input name="EngineeringName" id="EngineeringName" type="text" maxlength="100" style="width:90%;" readonly="readonly" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.EngineeringName}==null ? ' ':${personalWellInfoEntity.EngineeringName}">
                                                	<input name="EngineeringGuid" type="hidden" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.EngineeringGuid}==null ? ' ':${personalWellInfoEntity.EngineeringGuid}">
                                                	<span id="btnCompany" class="OpenWin" shiro:hasPermission="project:projectAll:lists" onclick="selectProject('选择项目 ')"></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px; width: 18%;">所在企业
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%; text-align: left;">
                                                    <input name="CompanyName" id="CompanyName" type="text" maxlength="100" style="width:90%;" readonly="readonly" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.CompanyName}==null ? ' ':${personalWellInfoEntity.CompanyName}">
                                                    <input name="CompanyGuid" type="hidden" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.CompanyGuid}==null ? ' ':${personalWellInfoEntity.CompanyGuid}">
                                                    <span id="btnCompany" class="OpenWin" shiro:hasPermission="enterprise:enterpriseAll:list" onclick="selectEnterprises('选择企业  ')"></span>
                                                </td>
                                                <td class="tdTitle" style="width: 18%;">
									                                                    组织机构代码/&nbsp;<br>
									                                                    统一社会信用代码<font color="red">*</font>
                                                </td>
                                                <td class="tdContent" style="width: 32%">
                                                    <input name="OrginGuid" id="OrginGuid" type="text" readonly="readonly" class="txtSingleBox"
                                                        style="width:100%;" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.OrginGuid}==null ? ' ':${personalWellInfoEntity.OrginGuid}">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px;">发生地所在市县
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent">
                                                    <input name="City" type="text" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.City}==null ? ' ':${personalWellInfoEntity.City}" maxlength="100"
                                                        class="txtSingleBox" style="width:100%;">
                                                </td>
                                                <td class="tdTitle">所属区</td>
                                                <td class="tdContent" name="Area" style="width: 32%" th:text="${personalWellInfoEntity}==null or ${personalWellInfoEntity.Area}==null ? ' ':${personalWellInfoEntity.Area}"></td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px">奖励机构级别
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent">
                                                    <select name="InLevel" th:field="${personalWellInfoEntity.InLevel}"
                                                        style="width:99.5%;height: 28px;line-height: 150%;">
                                                        <option selected="selected" value=""></option>
                                                        <option value="国家级">国家级</option>
                                                        <option value="省级">省级</option>
                                                        <option value="市县级">市县级</option>
                                                    </select>
                                                </td>
                                                <td class="tdTitle">奖励机构<font color="red">*</font>
                                                </td>
                                                <td class="tdContent">
                                                    <input name="AgencyName" type="text" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.AgencyName}==null ? ' ':${personalWellInfoEntity.AgencyName}"
                                                        style="width:100%;">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px;">奖励决定文号
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent">
                                                    <input name="DocNumber" type="text" style="width:100%;" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.DocNumber}==null ? ' ':${personalWellInfoEntity.DocNumber}">
                                                </td>
                                                <td class="tdTitle">奖励决定日期<font color="red">*</font>
                                                </td>
                                                <td class="tdContent">
                                                    <div class="input-group date">
                                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                                        <!-- <input type="text" name="$dtAwardDate" id="dtAwardDate" class="form-control" value="2018-04-20"> -->
                                                        	<input type="text" name="AwardDate" class="time-input" id="sTime" placeholder="开始时间"/ autocomplete="off" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.AwardDate}==null ? ' ':${personalWellInfoEntity.AwardDate}">
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 32px;">登记人</td>
                                                <td class="tdContent">
                                                    <input id="txtRegPerson" name="RegPerson" style="width:80%;border:0;outline:none;" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.RegPerson}==null ? ' ':${personalWellInfoEntity.RegPerson}">
                                                    <input type="hidden" name="OwnerGuid" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.OwnerGuid}==null ? ' ':${personalWellInfoEntity.OwnerGuid}">
                                                </td>
                                                <td class="tdTitle">登记部门</td>
                                                <td class="tdContent">
                                                    <input id="txtRegDepartment" name="RegDepartment" style="width:80%;border:0;outline:none;" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.RegDepartment}==null ? ' ':${personalWellInfoEntity.RegDepartment}">
                                                    <input type="hidden" name="RegDepartmentGuid" th:value="${personalWellInfoEntity}==null or ${personalWellInfoEntity.RegDepartmentGuid}==null ? ' ':${personalWellInfoEntity.RegDepartmentGuid}">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" align="center" style="width: 18%; height: 32px">
                                                    <span id="labMaterials">相关材料</span>
                                                    <font color="red">*</font>
                                                </td>
                                                <td class="tdContent" colspan="3" align="left">
                                                    <div class="form-group" style="margin-bottom: 6px;margin-top: 6px;">
                                                    	<input type="hidden" name="Materials">
                                                    	<p class="iconfile" style="padding:4px;display:none">
                                                    		<span>
                                                    		  <i class="glyphicon glyphicon-file"></i>
                                                    		</span>
                                                    		<input name="FileNameOld" readonly="readonly" style="width:60%;border:0;outline:none;" class="hasPath" th:value="${FileNameOld}">
                                                    		<button type="button" onclick="delPath()">删除</button>
                                                    		<a th:if="${fileState == '1'}" class="btn btn-success btn-xs" th:onclick="openUrl([[${filePath}]],[[${personalWellInfoEntity.FileNameOld}]])"><i class="fa fa-edit"></i>下载</a>
                                                    		<a th:if="${fileState == '0'}" class="btn btn-success btn-xs" rel="noopener noreferrer" th:href="${filePath}" target="_blank"><i class="fa fa-edit"></i>下载</a>
                                                    	</p>
                                                        <div class="file-loading">
                                                            <input id="addFileGoodUpdate" class="file" type="file" name="addFileGoodUpdate"
                                                                data-theme="fas" data-show-preview="false">
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdTitle" style="height: 50px;">理由</td>
                                                <td class="tdContent" colspan="3">
                                                    <textarea name="reasonContent" rows="3" cols="20"
                                                        style="width:100%;" readonly="readonly" th:text="${igmar}==null or ${igmar.opinion}==null ? ' ':${igmar.opinion}"></textarea>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="tdContent" colspan="4"
                                                    style="text-align: left; padding: 5px; line-height: 1.5;">&nbsp;[注1]
                                                   		 表格项目中带<font color="red">*</font>的必须填。
                                                    <br>
                                                    &nbsp;[注2]
                                                    	相关材料为奖励决定文书、通报、通知等扫描件，必须是格式(*.jpg;*.jpeg;*.png;*.rar;*.zip;*.pdf)，文件大小不超过10M，文件名最大长度为50个字。
                                                    <br>
                                                    &nbsp;[注3] “保存”按钮可以将当前已填写的内容保存下来以便下次修改，“保存并上报”按钮将填写的内容直接提交至系统处理。
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="row">
		        <div class="col-sm-offset-5 col-sm-10">
		            <button type="button" class="btn btn-sm btn-primary" onclick="saveAndReport(this)"><i class="fa fa-check"></i>保存</button>&nbsp;
		            <button type="button" class="btn btn-sm btn-primary" onclick="saveAndReport(this)"><i class="fa fa-check"></i>保存并上报</button>&nbsp;
		            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
		        </div>
		    </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
    	var prefix = ctx+"integrityInformationAdd/peopleBehavior";
    	/* 隐藏域  */
    	var behaviorCode = $('input[name="BehaviorCode"]').val();
    	var personGuid = $('input[name ="PersonGuid"]').val();
    	var idcard = $('input[name ="IDCard"]').val();
    	/* 下载  */
    	function openUrl(filePath, FileNameOld){
    		window.location.href = ctx + 'integrityInformationAdd/peopleBehavior/download?resource='+filePath+'&fileName='+ encodeURI(FileNameOld);
    	}
	   // 添加企业采集
	    function addpeopleBehavior(content,identifyType){
	    	idcard = $('input[name ="IDCard"]').val();
	    	if($.common.isEmpty(idcard)){
	    		idcard = "0";
	    	}
	    	var url = prefix+"/peopleGoodBehavioStandard/"+identifyType+"/"+idcard;
	    	$.modal.open(content, url);
	    };
	    
	    function selectEnterprises(content){
	    	var url = prefix+"/selectEnterTable";
	    	$.modal.open(content, url);
	    };
	    
	    function selectProject(content){
	    	var url = prefix+"/selectProjectTable";
	    	$.modal.open(content, url);
	    };
	    
	    function selectPeople(content){
	    	var url = prefix+"/selectPeopleTable";
	    	$.modal.open(content, url);
	    }
	    /*编辑回显 分数   */
	    if($.isArray([[${subStr}]])){
 			if($('input[name="Score"]')){$('input[name="Score"]').remove();};
 				var scoreSelect = '<select name="Score" id="Scores" style="width:99.5%;height: 28px;line-height: 150%;display:none;"></select>';
 				$("#Score").html(scoreSelect);
 				$('select[name="Score"]').show();
 				for(var i = 0; i < [[${subStr}]].length; i++){
 					if([[${subStr}]][i] == [[${personalWellInfoEntity.Score}]]){
 						$('select[name="Score"]').append('<option selected="selected">'+[[${personalWellInfoEntity.Score}]]+'</option>');
 					}else{
 						$('select[name="Score"]').append('<option>'+[[${subStr}]][i]+'</option>');
 					}
 				}
 			}else{
 				if($('select[name="Score"]')){$('select[name="Score"]').remove();}
 				var scoreInput = '<input type="text" id="Scores" readonly="readonly" name="Score" style="width:100%;border:0;outline:none;color:red">';
 				$("#Score").html(scoreInput);
 				$('input[name="Score"]').val([[${personalWellInfoEntity.Score}]]);
 		};
 		/* 文件路径回显删除事件  */
    	function delPath(){
    		$('.iconfile').remove();
    		$('input[name="Materials"]').remove();
    	}
    	/*判断是否有文件路径 && 文件路径 赋值隐藏域   */
    	if($.common.isNotEmpty([[${personalWellInfoEntity.Materials}]])){
    		$('input[name="Materials"]').val([[${personalWellInfoEntity.Materials}]]);
    		//$('input[name="FileNameOld"]')
    		$('.iconfile').show();
    	}else{
    		$('.iconfile').remove();
    	}
    	/*layDate */
    	layui.use('laydate', function() {
		    var laydate = layui.laydate;
		    var startDate = laydate.render({
		        elem: '#sTime',
		        max:0,
		        theme: 'molv',
		        trigger: 'click',
		        done: function(value, date){
		        	$("#sTime").val(value);//强制把所选时间绑定到value上,避免检验第一次失效
		        	$("#formsubmit").validate().element($("#sTime"))
		        }
		    });
		});
    	/* 全局按钮变量  */
    	var contend ='';
        $("#addFileGoodUpdate").fileinput({
        	'theme': 'explorer-fas',
            'uploadUrl': prefix + "/addFileGoodUpdate",
            'uploadExtraData':function(){
            	var formData = $("#formsubmit").serializeArray();
            	var cwie = {};
            	for(var i = 0; i< formData.length; i++ ){
            		cwie[formData[i].name] = formData[i].value;
            	};
            	
	        	if(contend == "保存"){
	        		cwie.SaveOrReport = "保存";
	        	}else if(contend == "保存并上报"){
	        		cwie.SaveOrReport = "上报";
	        	}
	        	return cwie;
            },
            overwriteInitial: false,
            uploadAsync: false, //默认异步上传
            showUpload: false, //是否显示上传按钮
            showRemove : true, //显示移除按钮
            showPreview : true, //是否显示预览
            showCaption: true,//是否显示标题
            browseClass: "btn btn-primary", //按钮样式
            allowedFileExtensions: ['jpg', 'jpeg', 'png', 'rar', 'zip', 'pdf'],
            //dropZoneEnabled: true,//是否显示拖拽区域
            //minImageWidth: 50, //图片的最小宽度
            //minImageHeight: 50,//图片的最小高度
            //maxImageWidth: 1000,//图片的最大宽度
            //maxImageHeight: 1000,//图片的最大高度
            maxFileSize: 10240,//单位为kb，如果为0表示不限制文件大小
            //minFileCount: 0,
            //maxFileCount: 1, //表示允许同时上传的最大文件个数
            //deleteUrl: prefix + '/delFile',
            enctype: 'multipart/form-data',
            validateInitialCount:true,
            initialPreviewAsData: true
        }).on("filebatchselected", function(event, files){
        	$('.iconfile').remove();
        	if(files.length > 1){
        		$.modal.alertWarning("只能上传一个文件");
        		$(".fileinput-remove-button").click();
        	}
        	if(files[0] != undefined){
        		if(files[0].size > 10485760){
            		$.modal.alertWarning("文件大小不超过10M");
            		$(".fileinput-remove-button").click();
            	}
        		var filenameold = files[0].name.split('.');
        		var filename = filenameold[filenameold.length-1]
        		if(filename != 'jpg' && filename != 'jpeg' && filename != 'png' && filename != 'rar' && filename != 'zip' && filename != 'pdf'){
        			$.modal.alertWarning("请传入指定的文件格式");
        			$(".fileinput-remove-button").click();
        		}
        	}
        })
        .on("filebatchuploadsuccess", function(event,data,previewId,index) {
        	if(data.response.code == '0'){
        		var topWindow = $(window.parent.document);
	            var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel');
	            var $contentWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0].contentWindow;
        		$.modal.closeTab();
        		$contentWindow.$.modal.msgSuccess(data.response.msg);
        		$contentWindow.$.table.refresh();
        	}else{
        		$.modal.alertError(data.response.msg);
        	}
        });
        
        function behavior(behaviorCode){
        	personGuid = $('input[name ="PersonGuid"]').val();
        	idcard = $('input[name ="IDCard"]').val();
        	$.ajax({
        		url: prefix+"/addPeopleBehavioField",
        		data: { 
                    "behaviorCode": behaviorCode ,
                    "personGuid": personGuid , 
                    "idcard": idcard ,
                    "goodOrBad": "good"
                },
        		type: 'POST',
        		success:function (result) {
        			$('input[name="BehaviorCode"]').val(result.data.BehaviorCode);
        			$('input[name="BehaviorCategory"]').val(result.data.BehaviorCategory);
        			$('textarea[name="BehaviorDescription"]').val(result.data.BehaviorDescription);
        			$('input[name="MaxScores"]').val(result.data.MaxScores);
        			$('input[name="PointsAdded"]').val(result.data.pointsAdded);
        			if($.isArray(result.data.Score)){
        				if($('input[name="Score"]')){$('input[name="Score"]').remove();};
        				var scoreSelect = '<select name="Score" id="Scores" style="width:99.5%;height: 28px;line-height: 150%;display:none;"></select>';
        				$("#Score").html(scoreSelect);
        				$('select[name="Score"]').show();
        				$('select[name="Score"]').append('<option selected="selected" value=""></option>');
        				for(var i = 0; i < result.data.Score.length; i++){
        					$('select[name="Score"]').append('<option>'+result.data.Score[i]+'</option>');
        				}
        			}else{
        				if($('select[name="Score"]')){$('select[name="Score"]').remove();}
        				var scoreInput = '<input type="text" readonly="readonly" id="Scores" name="Score" style="width:100%;border:0;outline:none;color:red">';
        				$("#Score").html(scoreInput);
        				$('input[name="Score"]').val(result.data.Score);
        			};
        			/* 单独验证表单  */
        			$("#formsubmit").validate().element($("#BehaviorCode"));
        			$("#formsubmit").validate().element($("#Scores"));
        			//$.validate.form();
        		}
        	})
        }
        
        function people(personGuid,idcard){
        	behaviorCode = $('input[name="BehaviorCode"]').val();
        	$.ajax({
        		url: prefix+"/addPeopleField",
        		data: { 
                    "personGuid": personGuid  ,
                    "behaviorCode": behaviorCode ,
                    "idcard": idcard ,
                    "goodOrBad": "good"
                },
                type: 'POST',
                success:function (result) {
                	$('input[name="PersonName"]').val(result.data.PersonName);
        			$('input[name="PersonGuid"]').val(result.data.PersonGuid);
        			/* 遍历select option  设置选中  */
        			$('#IDCardTypeNum option').each(function(){
        				$(this).removeAttr("selected", true);
        				if($.common.trim($(this).val()) == $.common.trim(result.data.IDCardTypeNum)){
        		            $(this).attr("selected", true);
        		        }
        		    });
        			$('input[name="IDCard"]').val(result.data.IDCard);
        			$('input[name="PointsAdded"]').val(result.data.pointsAdded);
        			if(result.data.isUndo){
        				$.modal.alertWarning('该资质的良好行为已被撤销');	
        				$('input[name="BehaviorCode"]').val('');
            			$('input[name="BehaviorCategory"]').val('');
            			$('textarea[name="BehaviorDescription"]').val('');
            			$('input[name="MaxScores"]').val('');
            			$('input[name="PointsAdded"]').val('');
            			$('#Scores').remove();
        			}
        			/* 单独验证表单  */
        			$("#formsubmit").validate().element($("#PersonName"));
        			$("#formsubmit").validate().element($("#IDCard"));
        			$("#formsubmit").validate().element($("#IDCardTypeNum"));
                }
        	})
        }
        
        function enter(companyGuid){
        	$.ajax({
        		url: prefix+"/addEnterField",
        		data: { 
                    "companyGuid": companyGuid  
                },
        		type: 'POST',
        		success:function (result) {
        			$('input[name="CompanyName"]').val(result.data.CompanyName);
        			$('input[name="OrginGuid"]').val(result.data.OrginGuid);
        			/* $('input[name="PointsAdded"]').val(result.data.pointsAdded); */
        			$('input[name ="CompanyGuid"]').val(companyGuid);
        			/* 单独验证表单  */
        			$("#formsubmit").validate().element($("#CompanyName"));
        			$("#formsubmit").validate().element($("#OrginGuid"));
        			//$.validate.form();
        		}
        	})
        }
        
        function project(projectGuid){
        	$.ajax({
        		url: prefix+"/addProjectField",
        		data: { 
                    "projectGuid": projectGuid 
                },
        		type: 'POST',
        		success:function (result) {
        			$('input[name="EngineeringName"]').val(result.data.EngineeringName);
        			$('input[name="EngineeringGuid"]').val(result.data.EngineeringGuid);
        		}
        	})
        };
        /* jq.validate */
         var icon = "<i class='fa fa-times-circle'></i> ";
         $("#formsubmit").validate({
	        rules: {
	        	BehaviorCode: {
	                required: true
	            },
	            Score: {
	                required: true
	            },
	            AwardContent:{
	            	required: true
	            },
	            PersonName:{
	            	required: true
	            },
	            IDCardTypeNum:{
	            	required: true
	            },
	            CompanyName:{
	            	required: true
	            },
	            OrginGuid:{
	            	required: true
	            },
	            City:{
	            	required: true
	            },
	            InLevel:{
	            	required: true
	            },
	            AgencyName:{
	            	required: true
	            },
	            DocNumber:{
	            	required: true
	            },
	            AwardDate:{
	            	required: true
	            }
	        },
	        messages: {
	        	BehaviorCode: {
	                required: icon + "请选择良好行为 "
	            },
	            Score: {
	                required: icon + "请选择加分分值 "
	            },
	            AwardContent:{
	            	required: icon + "请输入获奖内容  "
	            },
	            PersonName:{
	            	required: icon + "请输入姓名   "
	            },
	            IDCardTypeNum:{
	            	required: icon + "请输入证件类型  "
	            },
	            CompanyName:{
	            	required: icon + "请输入企业名称   "
	            },
	            OrginGuid:{
	            	required: icon + "请输入组织机构代码  "
	            },
	            City:{
	            	required: icon + "请输入发生地所在市县 "
	            },
	            InLevel:{
	            	required: icon + "请输入奖励机构级别  "
	            },
	            AgencyName:{
	            	required: icon + "请输入奖励机构 "
	            },
	            DocNumber:{
	            	required: icon + "请输入奖励决定文号 "
	            },
	            AwardDate:{
	            	required: icon + "请输入奖励决定日期 "
	            }
	        },
	        focusCleanup: true
	    })
        /* 保存并上报 */
           function saveAndReport(dom) {
	        if ($.validate.form()) {
	        	contend = $(dom).text();
	        	if($.common.isEmpty($('#addFileGoodUpdate').val())){
	        		var formData = $("#formsubmit").serializeArray();
	        		if(contend == "保存"){
		        		//cwie.SaveOrReport = "保存";
		        		formData.push({"name": "SaveOrReport", "value": "保存"});
		        	}else if(contend == "保存并上报"){
		        		//cwie.SaveOrReport = "上报";
		        		formData.push({"name": "SaveOrReport", "value": "上报"});
		        	}
	        		$.operate.saveTab(prefix + "/personsGoodBehaviorSaveAndReportUpdate", formData);
	        	}else{
	        		$("#addFileGoodUpdate").fileinput('upload');
	        	}
	        }
	    }
    </script>
</body>

</html>